package main

import "fmt"

type Human1 interface {
	SayHello()
}

type Student1 struct {
	name  string
	age   int
	sex   string
	score int
}

type Teacher1 struct {
	name    string
	age     int
	sex     string
	subject string
}

func (s *Student1) SayHello() {
	fmt.Printf("大家好，我是%s，我今年%d岁，我是%s生，我的成绩是%d分\n", s.name, s.age, s.sex, s.score)
}

func (t *Teacher1) SayHello() {
	fmt.Printf("大家好，我是%s，我今年%d岁，我是%s生，我的学科是%d\n", t.name, t.age, t.sex, t.subject)
}

// 多态的实现
// 将接口作为函数参数
func SayHi(h Human1){
	h.SayHello()
}

func main() {
	stu := Student1{"鸣人",18,"男",99}
	SayHi(&stu)
	tch := Teacher{"卡卡西",31,"男","复制忍术"}
	SayHi(&tch)
}
